package com.lzy.product.apis.impl;

import com.github.pagehelper.PageInfo;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.product.apis.CouponProfitRecordServiceApi;
import com.lzy.product.common.util.CalendarUtil;
import com.lzy.product.common.util.MathExtUtil;
import com.lzy.product.dtos.CouponProfitRecordDto;
import com.lzy.product.service.CouponProfitRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 卡券宝收益记录服务
 * Created by WIN7 on 2018/1/2.
 */
@Service
public class CouponProfitRecordServiceApiImpl implements CouponProfitRecordServiceApi {

    @Autowired
    private CouponProfitRecordService couponProfitRecordService;

    @Override
    public Long insert(CouponProfitRecordDto dto) {
        return couponProfitRecordService.insert(dto);
    }

    @Override
    public Boolean update(CouponProfitRecordDto dto) {
        return couponProfitRecordService.update(dto);
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public CouponProfitRecordDto findById(Long id) {
        return couponProfitRecordService.findById(id);
    }

    @Override
    public List<CouponProfitRecordDto> query(CouponProfitRecordDto dto) {
        return null;
    }

    @Override
    public BigDecimal calculateDayProfit(BigDecimal dragonMoney, int months) {
        int days = CalendarUtil.daysBetween(months);
        //保留两位小数，去尾法
        return MathExtUtil.divideRoundDown(dragonMoney, new BigDecimal(days));
    }

    @Override
    public List<CouponProfitRecordDto> queryLimitedList() {
        return couponProfitRecordService.queryLimitedList();
    }

    @Override
    public PageInfo<CouponProfitRecordDto> selectList(Pager pager, CouponProfitRecordDto paramDto) {
        return couponProfitRecordService.selectList(pager, paramDto);
    }

    @Override
    public PageInfo<CouponProfitRecordDto> selectListByType(Pager pager, Long memberId, String type,Integer status) {
        return couponProfitRecordService.selectListByType(pager,memberId,type,status);
    }

    @Override
    public List<CouponProfitRecordDto> queryLimitedListByCommision() {
        return couponProfitRecordService.queryLimitedListByCommision();
    }

    @Override
    public BigDecimal limitMoney(Long memberId) {
        return couponProfitRecordService.limitMoney(memberId);
    }

    @Override
    public BigDecimal availableMoney(Long memberId) {
        return couponProfitRecordService.availableMoney(memberId);
    }
}
